
//
//  VideoDataCell.m
//  NEWS_W_Y_S
//
//  Created by lanou3g on 15/10/15.
//  Copyright © 2015年 lanou3g.jake. All rights reserved.
//

#import "VideoDataCell.h"
#import "VideoDataModel.h"
#import "UIImageView+WebCache.h"

@implementation VideoDataCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self layoutViews];
    }
    
    return self;
}

-(void)layoutViews{
    //详情列别的视频图片
    self.videoImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 100, 100)];
    [self.contentView addSubview:self.videoImageView];
    //名字
    self.videoNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(120, 10, [UIScreen mainScreen].bounds.size.width - 130, 45)];
    self.videoNameLabel.numberOfLines = 0;
    [self.contentView addSubview:self.videoNameLabel];
    //时间
    self.videoTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(120, 60, 60, 45)];
    [self.contentView addSubview:self.videoTimeLabel];
 
}


-(void)videoData:(VideoDataModel *)videoDataModel
{
    [self.videoImageView sd_setImageWithURL:[NSURL URLWithString:videoDataModel.cover] placeholderImage:[UIImage imageNamed:@"1"]];
    self.videoNameLabel.text = videoDataModel.title;
    
    if (videoDataModel.length % 60 < 10 && videoDataModel.length / 60 < 10) {
        self.videoTimeLabel.text = [NSString stringWithFormat:@"0%ld:0%ld", videoDataModel.length / 60, videoDataModel.length % 60];
    } else if (videoDataModel.length / 60 > 10 && videoDataModel.length % 60 > 10) {
        self.videoTimeLabel.text = [NSString stringWithFormat:@"%ld:%ld", videoDataModel.length / 60, videoDataModel.length % 60];
    } else if (videoDataModel.length % 60 < 10 && videoDataModel.length / 60 > 10){
        self.videoTimeLabel.text = [NSString stringWithFormat:@"%ld:0%ld", videoDataModel.length / 60, videoDataModel.length % 60];
    } else if (videoDataModel.length % 60 > 10 && videoDataModel.length / 60 < 10) {
        self.videoTimeLabel.text = [NSString stringWithFormat:@"0%ld:%ld", videoDataModel.length / 60, videoDataModel.length % 60];
    }

    
    
}

@end
